import java.util.Arrays;
import java.util.List;

public class LeetCode876 {
    public static void main(String[] args) {

    }

    public static ListNode middleNode(ListNode head) {
        ListNode middleNode = head;

        ListNode nextNode = head;
        int count = 1;
        while (nextNode != null) {
            if (count % 2 == 0) {
                middleNode = middleNode.next;
            }
            nextNode = nextNode.next;
            count++;
        }

        return middleNode;
    }

}
